package com.yykj.tencent.im.server.controller;

import com.yykj.tencent.im.server.bean.request.AccountImportRequest;
import com.yykj.tencent.im.server.bean.request.MultiAccountImportRequest;
import com.yykj.tencent.im.server.bean.request.QueryOnlineStatusRequest;
import com.yykj.tencent.im.server.bean.response.*;
import com.yykj.tencent.im.server.service.AccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
@Api(tags = "腾讯云通信--账号管理")
@RequestMapping("api/tencent/im/account")
public class AccountController {

    @Resource
    private AccountService accountService;

    @ApiOperation("导入单个帐号")
    @PostMapping("/import/single")
    public AccountImportResult singleImport(@RequestBody AccountImportRequest body) {
        return accountService.accountImport(body);
    }

    @ApiOperation("导入多个帐号")
    @PostMapping("/import/multi")
    public MultiAccountImportResult multiImport(@RequestBody MultiAccountImportRequest body) {
        return accountService.multiAccountImport(body);
    }

    @ApiOperation("删除帐号")
    @PostMapping("/delete")
    public AccountDeleteResult deleteAccount(@RequestBody List<String> userIds) {
        return accountService.accountDelete(userIds);
    }

    @ApiOperation("查询帐号")
    @PostMapping("/check")
    public AccountCheckResult checkAccount(@RequestBody List<String> userIds) {
        return accountService.accountCheck(userIds);
    }

    @ApiOperation("失效帐号登录状态")
    @GetMapping("/kick")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "String"),
    })
    public KickResult kick(@RequestParam(name = "userId") String userId) {
        return accountService.kick(userId);
    }


    /**
     * 查询帐号在线状态
     */
    @ApiOperation("查询帐号在线状态")
    @PostMapping("/online")
    public QueryOnlineStatusResult onlineStatus(@RequestBody QueryOnlineStatusRequest body) {
        return accountService.queryOnlineStatus(body);
    }

    @ApiOperation("查询帐号")
    @PostMapping("/portraitGet")
    public PortraitGetResult portraitGet(@RequestBody List<String> imIds) {
        return accountService.portraitGet(imIds);
    }

}
